import React, { useEffect, useState } from 'react';
//1 基于'ref={函数}'的方式,可以把创建的DOM元素(或者子组件的实例)赋值给box变量【不推荐】

export default function CaseOne() {
  const [num, setNum] = useState(0);
  const handle = () => {
    setNum(num + 1);
  };
  let box;
  useEffect(() => {
    console.log(box);
  }, []);
  return (
    <>
      <div className='demo'>
        <span className='num' ref={(x) => (box = x)}>
          {num}
        </span>
        <button onClick={handle}>新增</button>
      </div>
    </>
  );
}
